
<!DOCTYPE html>
<html>
<head>
    <title></title>
    @include('system::admin.Layouts.index-layui-head')      </head>
<body>

<div class="layuimini-container">

    <div class="layuimini-main">

        <fieldset class="table-search-fieldset">
            <legend>搜索信息</legend>
            <div style="margin: 10px 10px 10px 10px">
                <form class="layui-form layui-form-pane" action="">
                    <div class="layui-form-item">

                        <div class="layui-inline">
                            <label class="layui-form-label">姓名</label>
                            <div class="layui-input-inline">
                                <input type="text" data-search-type="like" name="name" autocomplete="off" class="layui-input">
                            </div>
                        </div>

                        <div class="layui-inline">
                            <label class="layui-form-label">手机号</label>
                            <div class="layui-input-inline">
                                <input type="text" data-search-type="like" name="phone" autocomplete="off" class="layui-input">
                            </div>
                        </div>

                        <div class="layui-inline">
                            <label class="layui-form-label">状态</label>
                            <div class="layui-input-inline">
                                <select data-search-type="=" name="status" lay-verify="required">
                                    <option value="-1">全部</option>
                                    @foreach($formSearch[334]->search_extend['search'] as $key=>$search_extend) <option value="{{$key}}">{{$search_extend}}</option> @endforeach
                                </select>
                            </div>
                        </div>





                        <div class="layui-inline">
                            <button type="submit" class="layui-btn layui-btn-primary"  lay-submit lay-filter="data-search-btn"><i class="layui-icon"></i> 搜 索</button>
                        </div>

                    </div>
                </form>
            </div>
        </fieldset>

        <script type="text/html" id="toolbar">
            <div class="layui-btn-container">

                <button class="layui-btn layui-btn-normal layui-btn-sm data-add-btn" lay-event="add"> 添加 </button>
                <button class="layui-btn layui-btn-sm layui-btn-danger data-delete-btn" lay-event="delete"> 删除 </button>

            </div>
        </script>


        <table class="layui-hide" id="currentTableId" lay-filter="currentTableFilter"></table>


        <script type="text/html" id="currentTableBar">

            <a class="layui-btn layui-btn-normal layui-btn-xs data-count-edit" lay-event="edit">编辑</a>
            <a style="margin-left: 0px;" class="layui-btn layui-btn-normal layui-btn-xs data-count-invalid invalid" lay-event="invalid">无效</a>

        </script>

    </div>

</div>

@include('system::admin.Layouts.index-layui-top')



<script>

    //扩展执行js
    function self_extend(obj,layui){
        $ = layui.jQuery, table = layui.table, allJs = layui.allJs, data = obj.data;
        if(obj.event == 'personnel'){

        }
        if(obj.event == 'invalid'){
            //询问框
            layer.confirm('确定要对本单位设置无效？', {
                btn: ['确定','取消'] //按钮
            }, function(){
                //layer.msg('的确很重要', {icon: 1});

                layer.msg('暂时不更改数据', {icon: 1});

            }, function(){

            });
        }

    }

</script>


<script>

    layui.use(['form', 'table','laydate','arrayJs','chinAdmin','allJs'], function () {

        var $ = layui.jquery, form = layui.form, table = layui.table,laydate = layui.laydate,chinAdmin = layui.chinAdmin,allJs = layui.allJs;

        //头部搜索初始化组件

        //所有的项配置
        var $cols = [
            {type: "checkbox", width: 50},
            //逐步放弃这种扩展方式，采用头部<script type="text/html" id="currentTableBar">块扩展
            {title: '操作', minWidth: 150, toolbar: '#currentTableBar', align: "center"},

            {field: 'company_id', width: '280', title: '公司',sort: parseInt('0'),templet: function(d){
                    //选择##防止没有报错
                    if(typeof(d.company) == "undefined" || d.company == null){
                        return "";
                    }else{
                        return d.company.company_name;
                    }
                }},
            {field: 'username', width: '80', title: '登录账号',sort: parseInt('0'),templet: function(d){
                    return d.username?d.username:'';
                }},
            {field: 'id', width: '80', title: 'id',sort: parseInt('0'),templet: function(d){
                    return d.id?d.id:'';
                }},
            {field: 'name', width: '150', title: '姓名',sort: parseInt('0'),templet: function(d){
                    return d.name?d.name:'';
                }},
            {field: 'phone', width: '200', title: '手机号',sort: parseInt('0'),templet: function(d){
                    return d.phone?d.phone:'';
                }},
            {field: 'type', width: '200', title: '账号类型',sort: parseInt('0'),templet: function(d){
                    //下拉
                    var type_extends_5 = JSON.parse('{!! (gettype($form[326]->extends) == 'array')?json_encode($form[326]->extends):($form[326]->extends?$form[326]->extends:"{}") !!}');

                    for(var i in type_extends_5){
                        if(i == d.type){
                            return '<button type="button" class="layui-btn layui-btn-xs">'+type_extends_5[i]+'</button>';
                        }
                    }
                }},
            {field: 'status', width: '80', title: '状态',sort: parseInt('0'),templet: function(d){
                    //活动开关
                    var status_extends = JSON.parse('{!! $form[334]->extends !!}');

                    return (d.status == "on")?'<button type="button" class="layui-btn layui-btn-xs">'+status_extends.name.on+'</button>':'<button type="button" class="layui-btn layui-btn-xs layui-btn-normal">'+status_extends.name.off+'</button>';
                }},

        ];

        //son子模板$cols扩展编辑项
        typeof self_extend_cols === "function" ? ($cols = self_extend_cols($cols,layui)) : false;

        //通用调用
        layui.$cols = $cols,layui.$ThisGet = '{{$ThisGet}}',layui.$class = 'Account',layui.$this_id = 'id',layui.$table = 'ca_account';
        chinAdmin.index(layui);


        //toolbar监听表格头部添加删除
        table.on('toolbar(currentTableFilter)', function (obj) {

            if (obj.event === 'add') {  // 监听添加操作

                var where_eq_shop_id = '{{$_GET["where_eq_shop_id"]??""}}';

                var index = layer.open({
                    title: '添加',
                    type: 2,
                    shade: 0.2,
                    maxmin: true,
                    shadeClose: true,
                    area: ['100%', '100%'],
                    @if(isset($_GET['where_eq_partner']))
                    content: '/chinadmin/admin/' + layui.$class + '/create_partner?default='+encodeURI('{"partner":"1","shop_id":"'+where_eq_shop_id+'","role_id":"6"}'),
                    @else
                    content: "/chinadmin/admin/" + layui.$class + "/create",
                    @endif
                });


            } else if (obj.event === 'delete') {  // 监听删除操作

                var checkStatus = table.checkStatus('currentTableId')
                    , datac = checkStatus.data;

                $.ajax({
                    type: "POST",
                    url: "/chinadmin/admin/" + layui.$class + "/del",
                    timeout: 100000, //超时时间设置，单位毫秒 为一秒
                    data: {
                        'datac': datac
                    },
                    dataType: "json",      //如果有此选项成功返回的json会自动变成对象，如果没有需要用JSON.parse()转换
                    success: function (data) {
                        layer.msg(data.msg);
                        table.reload('currentTableId');
                    }
                });

            }
        });

        //编辑删除操作
        table.on('tool(currentTableFilter)', function (obj) {

            var data = obj.data;

            typeof self_extend === "function" ? self_extend(obj, layui) : false;

            if (obj.event === 'edit') {

                var index = layer.open({
                    title: '编辑',
                    type: 2,
                    shade: 0.2,
                    maxmin: true,
                    shadeClose: true,
                    area: ['100%', '100%'],
                    @if(isset($_GET['where_eq_partner']))
                    content: "/chinadmin/admin/" + layui.$class + "/create_partner?id=" + data[layui.$this_id],
                    @else
                    content: "/chinadmin/admin/" + layui.$class + "/create?id=" + data[layui.$this_id],
                    @endif
                });

                return false;

            } else if (obj.event === 'delete') {

                layer.confirm('真的删除行么', function (index) {

                    $.ajax({
                        type: "POST",
                        url: "/chinadmin/admin/" + layui.$class + "/del",
                        timeout: 100000, //超时时间设置，单位毫秒 为一秒
                        data: {
                            'id': data[layui.$this_id]
                        },
                        dataType: "json",      //如果有此选项成功返回的json会自动变成对象，如果没有需要用JSON.parse()转换
                        success: function (data) {
                            layer.msg(data.msg);
                        }
                    });

                    //界面效果
                    obj.del();
                    layer.close(index);

                });

            }
        });


    });
</script>

</body>
</html>
